FROM golang:1.21.4-alpine3.18 as builder

ENV GO111MODULE=on \
    CGO_ENABLED=0 \
    GOOS=linux \
    GOPROXY=https://goproxy.cn,direct  \
    GOARCH=amd64

WORKDIR /go/src/gin-vue-admin/server
COPY . .

RUN go mod tidy \
    && go build -ldflags "-s -w" -o server .

FROM scratch
WORKDIR /go/src/gin-vue-admin/server
ENV TZ="Asia/Shanghai"

COPY --from=builder /go/src/gin-vue-admin/server/server ./
COPY --from=builder /go/src/gin-vue-admin/server/config.yaml ./

EXPOSE 8888
ENTRYPOINT ./server -c config.yaml
# docker build --no-cache -t harbor.baocloud.cn/xo-container/gin-server:v0.0.1 .